$(function() {
	$("#footer").load('footer.html', function() {});
	$('#login').click(function() {
		var tel = $('input[name="phone"]').val();
		var pwd = $('input[name="pwd"]').val();
		if(!tel) {
			easyDialog.open({
				container: {
					content: '手机号不能为空！'
				},
				autoClose: 1500
			});
		} else if(!pwd) {
			easyDialog.open({
				container: {
					content: '密码不能为空！'
				},
				autoClose: 1500
			});
		} else {
			$.ajax({
				url: host + '/MtmlAPI/Login',
				data: {
					cid: cid,
					phone: tel,
					pwd: pwd
				},
				type: 'POST',
				dataType: 'JSON',
				success: function(data) {
					if(data.state) {
						easyDialog.open({
							container: {
								content: data.message
							},
							autoClose: 1500
						});
						sessionStorage.obj = JSON.stringify(data)

						window.location.href = 'index.html';
						var str = sessionStorage.obj;
						var name = obj.data.Realname
						var pwd = obj.data.password
						var exp = new Date();                 
						exp.setTime(exp.getTime() + 60 * 1000 * 60 * 24); //24小时           
						document.cookie = "userName=" + name + ";expires=" + exp.toGMTString();                 
						document.cookie = "passWord=" + pwd + ";expires=" + exp.toGMTString();
					} else {
						easyDialog.open({
							container: {
								content: "账号或密码错误，请重新登录！"
							},
							autoClose: 1500
						});
					}
				}
			})
		}
	})

})